package by.grsu.as.page;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.spring.injection.annot.SpringBean;

import by.grsu.as.dao.DaoClient;
import by.grsu.as.model.Client;


@SuppressWarnings("serial")
public class ListClientsPage extends BasePage {
	@SpringBean
	private DaoClient clientDao;
	
	public ListClientsPage() {
		super();
		
		final List<Client> clients = clientDao.findAll();

		add(new ListView<Client>("list", clients) {
			@Override
			protected void populateItem(final ListItem<Client> item) {
				final Client client = item.getModelObject();
				item.add(new Label("clientId", String.valueOf(client.getId())));
				item.add(new Label("name", client.getName()));
				item.add(new Label("lastname", client.getLastname()));
				item.add(new Label("age", String.valueOf(client.getAge())));
				item.add(new Label("rentalDays", String.valueOf(client.getDays())));
				/*
				 * item.add(new Link<Client>("editLink",new Model<Client>(client)){
				 * 
				 * @Override public void onClick(){ setResponsePage(new
				 * EditClient(client)); } });
				 */
			}
		});
		/*
		 * add(new Link<Client>("createLink", new Model<Client>(new Client())) {
		 * 
		 * @Override public void onClick() { setResponsePage(new
		 * EditClient(getModelObject())); } });
		 */
	}

}
